<?php
/**
 * 个人简历
 */
namespace app\user\controller;

class Resume extends base
{


    public function index()
    {
        if ($this->request->isPost()) {
            $data = $this->request->post();
            $data['uid'] = $this->getLoginUser()->id;

            if (!empty($data['id'])) {
                if ($data['file'] != $data['old_file']) {
                    @unlink('./uploads/file/' . $data['old_file']);
                }
                return $this->update($data);
            }

            $result = $this->model->allowField(true)->save($data);

            if ($result) {

                return ajax_info(lang('Saved successfully'), 'y');
            }
            return ajax_info(lang('Submission Failed'));

        }
        $data = $this->model->where('uid', $this->getLoginUser()->id)->find();
        $this->assign(['data' => $data]);
        return $this->fetch();
    }
}
